<template>
  <div ref="PieChart02" style="width: 100%; height: 300px"></div>
  <!-- 固定格式 -->
</template>

<script>
import * as echarts from 'echarts'
// 固定格式

export default {
  data() {
    return {}
  },
  // 渲染 DOM 用 mounted
  mounted() {
    // 输出函数 initPie()
    this.initPie02()
  },
  methods: {
    // 有函数 initPie() 就要输出
    initPie02() {
      // 基于准备好的 DOM，初始化 echarts 实例
      const myChart = echarts.init(this.$refs.PieChart02)
      // 配置基本信息
      const option = {
        legend: {
          top: 'bottom',
          orient: 'vertical',
          x: 'left'
        },
        toolbox: {
          show: true,
          feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        series: [
          {
            name: 'Nightingale Chart',
            type: 'pie',
            radius: [20, 150],
            center: ['50%', '50%'],
            roseType: 'area',
            itemStyle: {
              borderRadius: 8
            },
            labelLine: {
              show: false
            },
            label: {
              normal: {
                position: 'inside'
              }
            },
            data: [
              { value: 40, name: 'rose 1' },
              { value: 38, name: 'rose 2' },
              { value: 32, name: 'rose 3' },
              { value: 30, name: 'rose 4' },
              { value: 28, name: 'rose 5' },
              { value: 26, name: 'rose 6' },
              { value: 22, name: 'rose 7' },
              { value: 18, name: 'rose 8' }
            ]
          }
        ]
      }
      // 3.0 绘制图表
      myChart.setOption(option)
    }
  }
}
</script>

<style lang="less" scoped></style>
